#include<iostream>
#include<cstring>
using namespace std;
typedef pair<int, int> PII;
#define x first 
#define y second
const int N = 110;
PII q[N * N];
PII pre[N][N];
int mp[N][N];
bool st[N][N];
int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
void bfs(int x, int y)
{
	int hh = 0, tt = 0;
	q[0] = make_pair(x, y);
	st[x][y] = 1;
	while (hh <= tt) {
		PII t = q[hh++];
		for (int i = 0; i < 4; i++) {
			int a = x + t.x;
			int b = y + t.y;
			if (mp[a][b] || st[a][b] || a < 0 || b < 0 || a >= 5 || b >= 5) {
				continue;
			}
			pre[a][b] = make_pair(t.x, t.y);
			st[a][b] = 1;
			q[++tt] = make_pair(a, b);
			if (a == 0 && b == 0) {
				return;	
			}
		}
	}
}
int main()
{
	for (int i = 0; i < 5; i++) {
		for (int j = 0; j < 5; j++) {
			cin >> mp[i][j];
		}
	}
	memset(pre, -1, sizeof(pre));
	bfs(4, 4);
	int u = 0;
	int v = 0;
	while (u >= 0 && v >= 0) {
		printf("(%d, %d)\n", u, v);
		PII temp = pre[u][v];
		u = temp.x;
		v = temp.y;
	}
	return 0;
}